# -*- coding: utf-8 -*-
import zipfile
from time import time
zFile = zipfile.ZipFile('4.zip')
from threading import Thread
'''********************将字典进行分组***********************'''
s = open('password4.txt','r')
content = s.readlines()     #分行读取字典
dics = int(len(content)/1000)
print('当前字典中变量个数为: %s' % str(len(content)))
print("字典将被分割为 %s 份" % str(dics))
group = []  #字典每行独立化,写入元组
for h in range(0,len(content)):
    password = str(content[h]).strip('\n')  #剔除换行符
    group.append(password)
start = time()

for i in range(0,dics):
    new_group = []
    for k in range(i * 1000, (i + 1) * 1000):
        new_group.append(group[k])

    print("正在进行第 %s 组字典爆破" % str(i + 1))


    for each in new_group:
        try:
            zFile.extractall(pwd=bytes(each.strip(), 'utf-8'))
            print('the password is:' + each )
            print('找到密码所需时间:%s' % (time() - start)+ '\n')
        except:
            pass
    i+=1
print('遍历完字典所需时间:%s' % (time() - start)+ '\n')

